import {
  postParam,
  get
} from "./utils/service"
import Notify from './miniprogram_npm/@vant/weapp/notify/notify'
var app = getApp()
// app.js
//组件大全
//https://developers.weixin.qq.com/community/develop/article/doc/000ecc775a86807f7ba9b7dc956c13
//收费组件
//https://www.graceui.com/animate/info/10185-0.html
App({
  onLaunch() {
    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)
    const self = this
    //获取纸板打印费单价
    get(`https://api.landidz.com/order/paperFee`, {}, {
      success: function (d) {
        self.globalData.paperFee = d
        console.info("===================== 纸板打印费单价 =================", d, self.globalData.paperFee)
      }
    })

    // 登录
    https: //developers.weixin.qq.com/community/develop/doc/0006026b3c83c0e244573a0025bc08
      wx.login({
        success: res => {
          console.info("=================== OPEN CODE ============", res.code)
          //发送 res.code 到后台换取 openId, sessionKey, unionId
          postParam("https://api.landidz.com/user/wx/mini", {
            code: res.code
          }, {
            success: function (data) {
              console.info(data, "================ MINI USER-INFO ==============")
              self.globalData.openId = data.openId
            },
            fail: function (err) {
              console.error(err)
            }
          })
        }
      })
  },
  globalData: {
    userInfo: null,
    token: "d9c23d88-f8c6-44e9-975a-c0a1cead93c4",
    isFree: false,
    host: "https://api.landidz.com",
    recevier: null,
    orderId: "74d8fa473ada11ec95260242c0a83003",
    paperFee: 400,
    openId: null
  }
})

//表格
//https://www.yiyongtong.com/archives/view-7536-1.html